(function () {
    var EVENT_CLICK = Laya.Event.CLICK;
    var io = ppt.io;

    function roleSkill(call) {
        roleSkill.super(this);
        this.callback = call;
        this.data = null;
        this.init();
    }
    Laya.class(roleSkill, "Com.Role.Skill", ui.Role.RoleSkillUI);
    var _proto = roleSkill.prototype;

    _proto.init = function () {
        this.bindEvent();
    }
    _proto.skillPhoto = function (data) {
        this.data = data;
        for (var j = 0; j < 5; j++) {
            if (j < this.data.star) {
                this.expPicall.getChildByName("expPic" + (j + 1)).gray = false;
            }
        }
        for (var k = 0; k < this.data.skill.length; k++) {
            this.expPicall.getChildByName("expPic" + (k + 1)).skin = 'res/skill/' + (this.data.skill[k].skillType) + '.png';
        }
    }
    _proto.skillNum = function (starLength) {
        for (var j = 0; j < 5; j++) {
            if (j < starLength) {
                this.expPicall.getChildByName("expPic" + (j + 1)).gray = false;
            }
        }
    }
    _proto.bindEvent = function () {
        this.expPicall.getChildByName("expPic" + 1).on(Laya.Event.CLICK, this, function () {
            this.skillContent(0);

        });
        this.expPicall.getChildByName("expPic" + 2).on(Laya.Event.CLICK, this, function () {
            this.skillContent(1);
            this._skillIndex = 1;
        });
        this.expPicall.getChildByName("expPic" + 3).on(Laya.Event.CLICK, this, function () {
            this.skillContent(2);
            this._skillIndex = 2;
        });
        this.expPicall.getChildByName("expPic" + 4).on(Laya.Event.CLICK, this, function () {
            this.skillContent(3);

        });
        this.expPicall.getChildByName("expPic" + 5).on(Laya.Event.CLICK, this, function () {
            this.skillContent(4);

        });
    }
    //技能升级
    _proto.skillContent = function (type) {
        this._type = type;
        io.emit({ "cmd": "role::roleList", params: {} });
        this.callback(this._type);

    }
    _proto.skillUp = function (type) {
        var up = utils.createSkeleton('res/role/up');
        this.expPicall.addChild(up);
        up.zOrder = -1;
        up.play('skill', false);
        up.pos(10 + 90 * type, 20);
        up.once(Laya.Event.STOPPED, up, function () {
            this.visible = false;
        });
    }
})();